package com.cq.hd.member.controller;

import com.cq.hd.common.pagination.Page;
import com.cq.hd.common.response.Result;
import com.cq.hd.common.response.ResultGenerator;
import com.cq.hd.member.api.TbFeedbackApi;
import com.cq.hd.member.api.dto.FeedbackPageDto;
import com.cq.hd.member.api.dto.FeedbackSaveDto;
import com.cq.hd.member.api.vo.FeedbackPageVo;
import com.cq.hd.member.service.TbFeedbackService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 反馈建议表 前端控制器
 * </p>
 *
 * @author mYunYu
 * @since 2023-11-19
 */
@RestController
public class TbFeedbackController implements TbFeedbackApi {

    @Autowired
    private TbFeedbackService feedbackService;

    @ApiOperation(value = "反馈建议列表")
    @ApiImplicitParam(name = "feedbackPageDto", value = "反馈建议实体", required = true, paramType = "query", dataType = "FeedbackPageDto")
    @ApiResponse(response = FeedbackPageVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<Page<FeedbackPageVo>> pageFeedback(FeedbackPageDto feedbackPageDto) {
        return ResultGenerator.success(feedbackService.pageFeedback(feedbackPageDto));
    }

    @ApiOperation(value = "反馈建议详情")
    @ApiImplicitParam(name = "id", value = "反馈建议id", required = true, paramType = "query", dataType = "Long")
    @ApiResponse(response = FeedbackPageVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<FeedbackPageVo> details(Long id) {
        return ResultGenerator.success(feedbackService.details(id));
    }

    @ApiOperation(value = "提交反馈建议")
    @ApiImplicitParam(name = "feedbackSaveDto", value = "实体", required = true, paramType = "body", dataType = "FeedbackSaveDto")
    @Override
    public Result<Boolean> saveFeedback(@RequestBody FeedbackSaveDto feedbackSaveDto) {
        return ResultGenerator.success(feedbackService.saveFeedback(feedbackSaveDto));
    }

}
